module.exports = (sequelize, DataTypes) => {
  const comment = sequelize.define('comment', {
    time: DataTypes.DATE,
    content: DataTypes.STRING,
    // ip: DataTypes.STRING(50),
    isTop: {
      type: DataTypes.INTEGER,
      defaultValue: 0
    }
    // goodId
    // userId
  })

  comment.associate = (models) => {
    comment.belongsTo(models.good, {
      foreignKey: 'goodId',
      targergetKey: 'id',
      as: 'good'
    })
    comment.belongsTo(models.user, {
      foreignKey: 'userId',
      targergetKey: 'userId',
      as: 'user'
    })
    // comment.belongTo(models.manager, {
    //   foreignKey: 'managerId',
    //   targergetKey: 'managerId',
    //   as: 'manager'
    // })
  }
  return comment
}